package com.hnevc.androidui7;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class Activity03 extends AppCompatActivity {

    Button mBtn2;  //保存按钮
    EditText mEtAmount; //保存输入文本框
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_03);


        mBtn2 = findViewById(R.id.btn_button2);
        mEtAmount = findViewById(R.id.et_amount);//根据id找到控件

        mBtn2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //回传数据
                String amount = mEtAmount.getText().toString(); //获取文本框中的数据
                Intent intent = new Intent();
                intent.putExtra("data",amount);  //创建intent，包装数据，用于回传
                setResult(1003,intent);      //将intent回传
                finish();  //关闭当前activity
            }
        });


    }
}
